package com.night.icm.persistence.base.repository;

import com.night.icm.persistence.base.entity.Class;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.query.Param;
import org.springframework.stereotype.Repository;

/**
 * ClassRepository
 *
 * @author Liao ZhiYong
 * @date 2020/1/28
 */
@Repository
public interface ClassRepository extends JpaRepository<Class, Long>, JpaSpecificationExecutor<Class> {

    /**
     * 根据code和professionId查找班级
     *
     * @param code         班级编号
     * @param professionId 专业id
     * @return 班级信息
     */
    @Query("select c.id from Class as c where c.code = :code and c.profession.id = :professionId")
    Long findByCodeAndOProfessionId(@Param("code") String code, @Param("professionId") Long professionId);
}
